home *** CD-ROM | disk | FTP | other *** search
- #ifndef PHASH
-
- #ifndef MINPRIO
- #include <lwp/lwp.h>
- #endif
- #include <lwp/stackdep.h>
- #include "timer.h"
-
- #define OUTBUFSIZE 512 /* Size to be malloc'ed for outbuf */
-
- /* Kernel process control block */
- #define PHASH 16 /* Number of wait table hash chains */
- struct proc {
- struct proc *prev; /* Process table pointers */
- struct proc *next;
-
- char i_state; /* Process interrupt state */
-
- unsigned short state;
- #define READY 0
- #define WAITING 1
- #define SUSPEND 2
- void *event; /* Wait event */
-
- /* As the man page for LWPs states, stacks are problematic for light-weight
- processes... this is a major understatement!
- Our approach:
- Stacks must be aligned on a sktalign_t boundary... but we really need
- to deal with stack sizes consistently. So, we will define the stack
- as an array of type int... and we will deal with it as such.
- stkalign_t is defined as an int on the Sun386i and the Sun-3 machines,
- and as a double on the SPARC (Sun-4) machines. We will align to a
- doubleword boundary on all, and avoid the whole stkalign_t bit.
-
- For easier stack manipulations, we will record the stack bottom
- as well. This is the chunk we malloc'd for the stack. The first
- int is used to mark the stack bottom, and the remainder may
- be filled with the stack pattern. This can then be quickly tested
- to find overrun stacks and such. */
-
- int *stack; /* Process stack */
- int stksize; /* Size of same (in ints) */
- int *stackbottom; /* Bottom of the stack */
-
- char *name; /* Arbitrary user-assigned name */
- int retval; /* Return value from next pwait() */
- struct timer alarm; /* Alarm clock timer */
- struct mbuf *outbuf; /* Terminal output buffer */
- int input; /* standard input socket */
- int output; /* standard output socket */
- int iarg; /* Copy of iarg */
- void *parg1; /* Copy of parg1 */
- void *parg2; /* Copy of parg2 */
- int freeargs; /* Free args on termination if set */
- thread_t tid; /* LWP thread ID */
- };
- #define NULLPROC (struct proc *)0
- extern struct proc *Waittab[]; /* Head of wait list */
- extern struct proc *Rdytab; /* Head of ready list */
- extern struct proc *Curproc; /* Currently running process */
-
- /* In kernel.c: */
- void alert __ARGS((struct proc *pp,int val));
- void chname __ARGS((struct proc *pp,char *newname));
- void killproc __ARGS((struct proc *pp));
- void killself __ARGS((void));
- struct proc *mainproc __ARGS((char *name));
- struct proc *newproc __ARGS((char *name,unsigned int stksize,
- void (*pc) __ARGS((int,void *,void *)),
- int iarg,void *parg1,void *parg2,int freeargs));
- int psignal __ARGS((void *event,int n));
- int pwait __ARGS((void *event));
-
- #define STACKPAT 0x5a6b7c8d
- #define STACKBOT 0x12345678
-
- #endif /* PHASH */
-